package org.aphelie.romancer.model.editor.impl;

import java.util.Map;

import org.aphelie.romancer.model.editor.RomancerEditorResourceManager;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

public class RomancerEditorResourceManagerImpl extends ResourceSetImpl implements RomancerEditorResourceManager {

	/* Singleton instanciation */
	
	/**
	 * The singleton instance of this class 
	 */
	private static final RomancerEditorResourceManager INSTANCE = new RomancerEditorResourceManagerImpl();
	
	/**
	 * Returns the singleton instance of this class
	 * @return the singleton instance of this class
	 */
	public static RomancerEditorResourceManager getInstance() {
		return INSTANCE;
	}
	
	/**
	 * Default constructor
	 */
	private RomancerEditorResourceManagerImpl() {
		super();
		initExtensionToFactoryMap();
	}
	
	/* Resource.Factory.Registry */
	private Map<String, Object> extensionToFactoryMap;
	
	// TODO
	private String[] extensions = {"chronicle", "character"};
	
	private void initExtensionToFactoryMap() {
		if (extensionToFactoryMap == null) {
			extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
		}
		for (String extension : extensions) {
			extensionToFactoryMap.put(extension, new XMIResourceFactoryImpl());
		}
	}
	
}
